/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.CustomerManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.thread.DeleteCustomerThread;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class DeleteAppCustomer extends AbstractAction
/*    */ {
/* 29 */   private static Logger logger = Logger.getLogger(DeleteAppCustomer.class
/* 30 */     .getName());
/*    */ 
/* 32 */   private String indexPath = null;
/*    */ 
/*    */   public DeleteAppCustomer(AbstractHttpServlet servlet, String indexPath) {
/* 35 */     super(servlet);
/* 36 */     this.indexPath = indexPath;
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 42 */     User user = super.getLoginUser(request);
/* 43 */     int customerId = Util.str2Int(request.getParameter("customerId"));
/*    */ 
/* 45 */     String ip = Util.getClientIpAddr(request);
/* 46 */     logger.warn("ip:" + ip + " / 用户Id：" + user.userId + " /  用户名：" + 
/* 47 */       user.name + ", 删除了公司：id： " + customerId);
/*    */ 
/* 49 */     int count = 0;
/* 50 */     CustomerManager manager = new CustomerManager();
/*    */     try {
/* 52 */       count = manager.deleteCustomer(customerId, user.isAdmin, 
/* 53 */         user.userId, user.companyId);
/*    */     } catch (DBException e) {
/* 55 */       logger.warn("delete customer failed", e);
/*    */     }
/*    */ 
/* 58 */     response.setContentType("text/html;charset=utf-8");
/* 59 */     PrintWriter out = response.getWriter();
/* 60 */     JSONObject jsonObject = new JSONObject();
/*    */ 
/* 62 */     if (count > 0) {
/* 63 */       jsonObject.put("error", "0");
/*    */ 
/* 66 */       new Thread(new DeleteCustomerThread(this.indexPath)).start();
/*    */     } else {
/* 68 */       jsonObject.put("error", "1");
/* 69 */       jsonObject.put("msg", "删除客户信息失败，请稍后重试");
/*    */     }
/* 71 */     out.println(jsonObject);
/* 72 */     out.flush();
/* 73 */     out.close();
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.DeleteAppCustomer
 * JD-Core Version:    0.6.1
 */